import AnimatorBase from "db://app-game/libs/animator/core/AnimatorBase";
import { AnimatorStateLogic } from "db://app-game/libs/animator/core/AnimatorStateLogic";
import { Role } from "../../../Role";
import { AnimationEventHandler } from "../AnimationEventHandler";

/** 上半身攻击动画逻辑 */
export class RoleUpperStateAttacks<T> extends AnimatorStateLogic {
  /** 角色 */
  private role: Role;
  private anim: AnimationEventHandler<T>;

  public constructor(role: Role, anim: AnimationEventHandler<T>) {
    super();
    this.role = role;
    this.anim = anim;
    this.anim.addFrameEvent("attack", this.attackCallback, this);
  }

  /** 攻击事件回调 */
  private attackCallback(type: string, target: AnimatorBase, params: T) {
    if (params) {
      this.attack(type, target, params);
    } else {
      this.attackMove(type, target, params);
    }
  }

  /** 攻击 */
  private attack(type: string, target: AnimatorBase, param: T) {}

  /** 攻击移动 */
  private attackMove(type: string, target: AnimatorBase, param: T) {}

  public onEntry(): void {}
  public onUpdate(): void {}
  public onExit(): void {}
}
